import React from "react"
import { useLocation } from "react-router-dom"
import { Breadcrumb } from "antd"
import items from "../siderMenu/menuList"
function BreadcrumbTitle() {
  const location = useLocation()
  const findSelect = (item) => item.key === location.pathname
  function handleSelect(arr) {
    let att = []
    const resSignal = arr.find(findSelect)
    att = [{ key: resSignal?.key, title: resSignal?.label }]
    arr.forEach((ele) => {
      if (ele["children"]) {
        const arrsss = handleSelect(ele["children"])
        if (arrsss.length) {
          att = [{ key: ele.key, title: ele.label }, ...arrsss]
        }
      }
    })
    return att.filter((item) => item?.title && item?.title)
  }
  return (
    <Breadcrumb
      className="mb-10px h-46px bg-white py-14px pl-24px box-border"
      items={handleSelect(items)}
    ></Breadcrumb>
  )
}
export default BreadcrumbTitle
